--------------------------------------
----------- CAPITULO 17 ---------------
--------------------------------------

-- Ejercicio 1
ejercicio1 = [ x + y | x <- [1..4], y <- [2..4], x > y]

-- Ejercicio 3
--perms [] = [[]]
--perms xs = [ x:ps | x <- xs , ps <- perms (xs\\[x]) ]

perm :: [a] ->  [[a]]
perm [] = [[]]
perm (x:xs) = [ ps ++ [x] ++ qs | rs <- perm xs , (ps,qs) <- splits rs ]

splits :: [a] -> [( [a] , [a] ) ]
splits [] = [( [] , [] ) ]
splits (y:ys) =  ([] , y : ys) : [ ( y : ps, qs ) | ( ps, qs) <- splits ys ]